function total_costs = calc_adaptation_costs(CDD_final,CDD_initial,beta_final,beta_initial,years)

alpha_vec = (CDD_final-CDD_initial)./years;
alpha_beta_vec = (beta_final-beta_initial)./years;

marginal_cost_mat = [];
lag_year_index = ['y' num2str(2020)];
CDD.y2020 = CDD_initial;
beta.y2020 = beta_initial;
for year = 2021:1:2090
    year_index = ['y' num2str(year)];
    CDD.(year_index) = CDD.(lag_year_index)+alpha_vec;
    beta.(year_index) = beta.(lag_year_index)+alpha_beta_vec;
    marginal_cost_mat = [marginal_cost_mat CDD.(year_index).*(beta.(year_index)-beta.(lag_year_index))];
    lag_year_index = year_index;
end

total_costs = sum(marginal_cost_mat,2);

end